#include <iostream>
using namespace std;

signed main()
{
    int n;
    cin>>n;
    int maxNum = 0,maxSales = 0;
    string s1,s2;
    for(int i=0;i<n;i++){
        string s;
        int prime,num;
        cin>>s>>prime>>num;
        if(num>=maxNum){
            s1 = s;
            maxNum = num;
        }
        if(prime*num>=maxSales){
            s2 = s;
            maxSales = prime*num;
        }
    }
    cout<<s1<<" "<<maxNum<<"\n";
    cout<<s2<<" "<<maxSales<<"\n";
    return 0;
}
